package dao

import (
	"golang.org/x/net/context"
	"sale-admin/internal/dal"
)

type IMaGoodsClassFilter interface {
	fmtFilter(ctx context.Context, tx dal.IMaGoodsClassDo, q *dal.Query) dal.IMaGoodsClassDo
}

var _ IMaGoodsClassFilter = (*MaGoodsClassFilter)(nil)

type MaGoodsClassFilter struct {
	ID string
}

// 筛选器
func (p *MaGoodsClassFilter) fmtFilter(ctx context.Context, tx dal.IMaGoodsClassDo, q *dal.Query) dal.IMaGoodsClassDo {
	if p.ID != "" {
		tx = tx.Where(q.MaGoodsClass.ID.Eq(p.ID))
	}

	return tx
}

type MaGoodsClassListFilter struct {
	ID string
}

func (p *MaGoodsClassListFilter) fmtFilter(ctx context.Context, tx dal.IMaGoodsClassDo, q *dal.Query) dal.IMaGoodsClassDo {
	if p.ID != "" {
		tx = tx.Where(q.MaGoodsClass.ID.Eq(p.ID))
	}

	return tx
}
